#ifndef FIREWORKPARTICLE_H
#define FIREWORKPARTICLE_H

#include <deque>
#include <vector>

#include "Particle.h"

class FireworkParticle : public Particle {
public:
	FireworkParticle() = default;
	FireworkParticle(vsg::dvec3 pos, vsg::dvec3 speed, double dragCoefficient, vsg::vec4 color, uint8_t trailLength)
		: Particle{ pos, speed, dragCoefficient, color },
		m_trailLength{ trailLength } {};

	~FireworkParticle() {};

	virtual void update(const std::chrono::nanoseconds& delt) override;
	virtual vsg::ref_ptr<vsg::Node> getNode() override;

	virtual void activate() override;
	void setTrailLength(uint8_t length) {
		m_trailLength = length;
	}
protected:
	virtual void invalid() override;

private:
	void initNode();

private:
	uint8_t m_trailLength;
	std::deque<vsg::dvec3> m_oldPos;
	vsg::ref_ptr<vsg::MatrixTransform> m_trailMatrixTransform;
	vsg::ref_ptr<vsg::Switch> m_switch;
	vsg::ref_ptr<vsg::vec4Array> m_trailColors;
};

#endif
